<?php
class M_tags extends Module {
  public function main() {
    $sql = "SELECT * FROM `tags_names` WHERE 1 ORDER BY `tag`";
    $res = db::q( $sql );

    if ( Site::$ajax ) {
      header( 'Content-Type: text/xml' );
      $xml = new Template('xml');
      while ( $r = $res->assoc() ) {
        $xml->add( 'data', "<tag>".$r['name']."</tag>");
      }
      echo $xml;
    } else {
      $tagcloud = mod_load('tagcloud');
      $tagcloud->param( 'all', true );
      return $tagcloud->main();
    }
  }
}
?>